﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
namespace AnyOffice.general.person_info
{
    public partial class pass : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.litCurrentUserId.Text = base.User.Identity.Name;
            }
            if (this.Page.IsPostBack)
            {
                this.pnlMain.Visible = false;
                string oldPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtOldPass.Text, "md5");
                string newPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtNewPass.Text, "md5");
                UsersDao dao = new UsersDao();
                if (dao.ChangePassword(base.Conn, base.User.Identity.Name, oldPassword, newPassword))
                {
                    this.litMessage.Text = base.ShowPrompt("密码修改成功！", "index.aspx");
                    string remark = "UserId=" + base.User.Identity.Name;
                    SysLog.Log(base.Conn, 14, remark);
                }
                else
                {
                    this.litMessage.Text = base.ShowPrompt("密码修改失败，原密码不正确！");
                }
            }
        } 

    }
}
